﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace DataConvertLib
{
	/// <summary>
	/// 非常好用的字节集合类
	/// </summary>
	// Token: 0x02000003 RID: 3
	[Description("非常好用的字节集合类")]
	public class ByteArray
	{
		/// <summary>
		/// 通过索引获取值
		/// </summary>
		/// <param name="index">索引</param>
		/// <returns>返回字节</returns>
		// Token: 0x17000001 RID: 1
		public byte this[int index]
		{
			get
			{
				return this.list[index];
			}
			set
			{
				this.list[index] = value;
			}
		}

		/// <summary>
		/// 返回长度
		/// </summary>
		// Token: 0x17000002 RID: 2
		// (get) Token: 0x06000012 RID: 18 RVA: 0x000023F1 File Offset: 0x000005F1
		public int Length
		{
			get
			{
				return this.list.Count;
			}
		}

		/// <summary>
		/// 属性，返回字节数组
		/// </summary>
		// Token: 0x17000003 RID: 3
		// (get) Token: 0x06000013 RID: 19 RVA: 0x00002400 File Offset: 0x00000600
		public byte[] array
		{
			get
			{
				return this.list.ToArray();
			}
		}

		/// <summary>
		/// 清空字节数组
		/// </summary>
		// Token: 0x06000014 RID: 20 RVA: 0x0000241D File Offset: 0x0000061D
		[Description("清空字节数组")]
		public void Clear()
		{
			this.list = new List<byte>();
		}

		/// <summary>
		/// 添加一个字节
		/// </summary>
		/// <param name="item">字节</param>
		// Token: 0x06000015 RID: 21 RVA: 0x0000242B File Offset: 0x0000062B
		[Description("添加一个字节")]
		public void Add(byte item)
		{
			this.Add(new byte[]
			{
				item
			});
		}

		/// <summary>
		/// 添加一个字节数组
		/// </summary>
		/// <param name="items">字节数组</param>
		// Token: 0x06000016 RID: 22 RVA: 0x0000243F File Offset: 0x0000063F
		[Description("添加一个字节数组")]
		public void Add(byte[] items)
		{
			this.list.AddRange(items);
		}

		/// <summary>
		/// 添加二个字节
		/// </summary>
		/// <param name="item1">字节1</param>
		/// <param name="item2">字节2</param>
		// Token: 0x06000017 RID: 23 RVA: 0x0000244F File Offset: 0x0000064F
		[Description("添加二个字节")]
		public void Add(byte item1, byte item2)
		{
			this.Add(new byte[]
			{
				item1,
				item2
			});
		}

		/// <summary>
		/// 添加三个字节
		/// </summary>
		/// <param name="item1">字节1</param>
		/// <param name="item2">字节2</param>
		/// <param name="item3">字节3</param>
		// Token: 0x06000018 RID: 24 RVA: 0x00002467 File Offset: 0x00000667
		[Description("添加三个字节")]
		public void Add(byte item1, byte item2, byte item3)
		{
			this.Add(new byte[]
			{
				item1,
				item2,
				item3
			});
		}

		/// <summary>
		/// 添加四个字节
		/// </summary>
		/// <param name="item1">字节1</param>
		/// <param name="item2">字节2</param>
		/// <param name="item3">字节3</param>
		/// <param name="item4">字节4</param>
		// Token: 0x06000019 RID: 25 RVA: 0x00002483 File Offset: 0x00000683
		[Description("添加四个字节")]
		public void Add(byte item1, byte item2, byte item3, byte item4)
		{
			this.Add(new byte[]
			{
				item1,
				item2,
				item3,
				item4
			});
		}

		/// <summary>
		/// 添加五个字节
		/// </summary>
		/// <param name="item1">字节1</param>
		/// <param name="item2">字节2</param>
		/// <param name="item3">字节3</param>
		/// <param name="item4">字节4</param>
		/// <param name="item5">字节5</param>
		// Token: 0x0600001A RID: 26 RVA: 0x000024A4 File Offset: 0x000006A4
		[Description("添加五个字节")]
		public void Add(byte item1, byte item2, byte item3, byte item4, byte item5)
		{
			this.Add(new byte[]
			{
				item1,
				item2,
				item3,
				item4,
				item5
			});
		}

		/// <summary>
		/// 添加一个ByteArray对象
		/// </summary>
		/// <param name="byteArray">ByteArray对象</param>
		// Token: 0x0600001B RID: 27 RVA: 0x000024CA File Offset: 0x000006CA
		[Description("添加一个ByteArray对象")]
		public void Add(ByteArray byteArray)
		{
			this.Add(byteArray.array);
		}

		/// <summary>
		/// 添加一个ushort类型数值
		/// </summary>
		/// <param name="value">ushort类型数值</param>
		// Token: 0x0600001C RID: 28 RVA: 0x000024DA File Offset: 0x000006DA
		[Description("添加一个ushort类型数值")]
		public void Add(ushort value)
		{
			this.list.Add((byte)(value >> 8));
			this.list.Add((byte)value);
		}

		/// <summary>
		/// 添加一个short类型数值
		/// </summary>
		/// <param name="value">short类型数值</param>
		// Token: 0x0600001D RID: 29 RVA: 0x000024FB File Offset: 0x000006FB
		[Description("添加一个short类型数值")]
		public void Add(short value)
		{
			this.list.Add((byte)(value >> 8));
			this.list.Add((byte)value);
		}

		// Token: 0x04000001 RID: 1
		private List<byte> list = new List<byte>();
	}
}
